package com.iknow.ui.model;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.iknow.data.SubscribeTag;
import java.util.ArrayList;
import java.util.List;

public class SubscribeTagAdapter extends BaseAdapter
{
  private final int TYPE_MY_TAG = 0;
  private final int TYPE_TAG = 1;
  private SubscribeTag mAllTag;
  private List<SubscribeTag> mFloatTag;
  private LayoutInflater mLayoutInflater;
  private SubscribeTag mMyTag = new SubscribeTag("订阅的标签", "1");
  private List<SubscribeTag> mTagList;

  public SubscribeTagAdapter(LayoutInflater paramLayoutInflater)
  {
    this.mAllTag = new SubscribeTag("全部标签", "1");
    this.mLayoutInflater = paramLayoutInflater;
    this.mTagList = new ArrayList();
    this.mFloatTag = new ArrayList();
    this.mFloatTag.add(this.mMyTag);
    this.mFloatTag.add(this.mAllTag);
  }

  private void fillData(int paramInt, View paramView)
  {
    SubscribeTag localSubscribeTag = getItem(paramInt);
    ViewHolder localViewHolder = (ViewHolder)paramView.getTag();
    localViewHolder.mTagName.setText(localSubscribeTag.getTagName());
    localViewHolder.mUnread_num.setVisibility(8);
  }

  private View newView()
  {
    View localView = this.mLayoutInflater.inflate(2130903048, null);
    ViewHolder localViewHolder = new ViewHolder(this, null);
    localViewHolder.mIcon = ((ImageView)localView.findViewById(2131296296));
    localViewHolder.mTagName = ((TextView)localView.findViewById(2131296297));
    localViewHolder.mUnread_num = ((TextView)localView.findViewById(2131296298));
    localViewHolder.mArrow = ((ImageView)localView.findViewById(2131296299));
    localView.setTag(localViewHolder);
    return localView;
  }

  public void addTagByString(SubscribeTag paramSubscribeTag)
  {
    this.mTagList.add(paramSubscribeTag);
  }

  public void clearTag()
  {
    this.mTagList.clear();
  }

  public int getCount()
  {
    return this.mTagList.size();
  }

  public SubscribeTag getItem(int paramInt)
  {
    return ((SubscribeTag)this.mTagList.get(paramInt));
  }

  public long getItemId(int paramInt)
  {
    return paramInt;
  }

  public View getView(int paramInt, View paramView, ViewGroup paramViewGroup)
  {
    View localView;
    if (this.mFloatTag.contains(getItem(paramInt)))
    {
      localView = this.mLayoutInflater.inflate(2130903056, null);
      ((TextView)localView.findViewById(2131296320)).setText(getItem(paramInt).getTagName());
    }
    while (true)
    {
      return localView;
      localView = newView();
      fillData(paramInt, localView);
    }
  }

  public int getViewTypeCount()
  {
    return 2;
  }

  public boolean isEnabled(int paramInt)
  {
    boolean bool;
    if (this.mFloatTag.contains(getItem(paramInt)))
      bool = false;
    while (true)
    {
      return bool;
      bool = super.isEnabled(paramInt);
    }
  }

  public void resetAllTagName(String paramString)
  {
    this.mAllTag.setTagName(paramString);
  }

  public void setMySubscribeTagList(List<SubscribeTag> paramList)
  {
    if (paramList != null)
    {
      this.mTagList.add(this.mMyTag);
      this.mTagList.addAll(paramList);
    }
  }

  public void setTagList(List<SubscribeTag> paramList)
  {
    this.mTagList.add(this.mAllTag);
    this.mTagList.addAll(paramList);
  }

  private class ViewHolder
  {
    ImageView mArrow;
    ImageView mIcon;
    TextView mTagName;
    TextView mUnread_num;
  }
}